package com.example.mq;

import com.example.mq.mqserver.BrokerServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;

import java.io.IOException;

@SpringBootApplication // Spring Boot 应用入口注解
public class DemoApplication implements ApplicationContextAware {
    public static ConfigurableApplicationContext context;

    public static void main(String[] args) throws IOException {
        // 启动 Spring Boot 应用，获取上下文
        context = SpringApplication.run(DemoApplication.class, args);
        // 创建并启动消息队列服务器，监听9090端口
        BrokerServer brokerServer=new BrokerServer(9090);
        brokerServer.start();
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) {
        context = (ConfigurableApplicationContext) applicationContext;
    }

}
